<?php

namespace App\Http\Controllers\AjaxRequest;
use Illuminate\Http\Request;
use Illuminate\Http\Response;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Input;

class CheckNameController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    private static $ip = '192.168.0.89';
    private static $port = '8080';

    public function index()
    {
         //echo "1234";
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  Request  $request
     * @return Response
     */
    public function store(Request $request)
    {
            $I_UserName = Input::get('I_UserName');
            $url = $ip.":".$port."/test/user/password?username=".$I_UserName;
            //$str1 =  "192.168.0.221:8080/test/user/password?username=";
            //$url = $str1."".$I_UserName;
            $ch = curl_init();
            curl_setopt($ch,CURLOPT_URL,$url); /*获取URL的内容*/
            curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
            curl_setopt($ch,CURLOPT_HEADER,0);
            //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);/*获取的内容不输出*/
            $content = curl_exec($ch);/*输出获取的内容*/
            //  $httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
            curl_close($ch);
            if($content==""){
            echo "1";
            }else{
            echo "0";
            }
          return response()->json($arrayName = array('user_name' => $I_UserName,));
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  Request  $request
     * @param  int  $id
     * @return Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return Response
     */
    public function destroy($id)
    {
        //
    }
}